package com.riddle.service;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSession;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.riddle.dao.ArticleDao;
import com.riddle.dao.BaseDao;
import com.riddle.model.Article;
import com.riddle.model.Category;

@Service
@Scope("prototype")  
public class ArticleService extends BaseService<Article> {

	@Resource
	private ArticleDao articleDao;
	
	protected  BaseDao getDao() {
		return articleDao;
	}
	
	public List<Article> getArticles(){
		return articleDao.getArticles();
	}
	
	public List<Article> getRecentArticles(){
		return articleDao.getRecentArticles();
	}
	
	public List<Category> getCategories(String query){
		return articleDao.getCategories(query);
	}
	
	public List<Category> getCategoriesWithCount(){
		return articleDao.getCategoriesWithCount();
	}
	
	public Category getCategoryWithArticles(Long id) {
		return articleDao.getCategoryWithArticles(id);
	}
}